

class Vehicle {
    brand
    year
    constructor(brand, year) {
        this.brand = brand
        this.year = year
        console.log(`品牌:${this.brand},生产年份:${this.year}年`);

    }
    #isHeli() {
        if (this.year > new Date().getFullYear()) {
            throw new Error('不能为未来的年份');
        }
    }
    getInfo() {
        return `父类的基本信息：品牌${brand},生产年份${year}`
    }
    static vehicleCount = 5
    static incrementVehicleCount() {
        this.vehicleCount += 3
        console.log('当前车辆数量:', this.vehicleCount);
    }

}

class Car extends Vehicle {
    mileage
    constructor(mileage, ...arg) {
        super(...arg)
        this.mileage = mileage
    }
    get mi() {
        return this.mileage
    }
    set mi(value) {
        this.mileage = value
    }
    drive() {
        this.mileage += 1000
        console.log(`${this.brand}增加后的里程数为: ${this.mileage}`);

    }
    getInfo() {
        return `子类的基本信息：品牌:${this.brand},生产年份:${this.year},里程数:${this.mileage}`
    }
    static compareMileage(car1, car2) {
        if (car1.mileage > car2.mileage) {
            console.log(car1.getInfo());
        } else {
            console.log(car2.getInfo());
        }
    }
}

let car1 = new Car(100, '法拉利', 2010)
let car2 = new Car(120, '兰博基尼', 2012)
car1.drive()
Car.compareMileage(car1, car2)
Vehicle.incrementVehicleCount()

